<?php
/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */

require_once "Artichow-php5/LinePlot.class.php";
require_once "Artichow-php5/BarPlot.class.php";

//$a = array(1,2,3,4,5,6,7,8,9,0);
//$t = array(1,2,3,4,5,6,7,8,9,0);
//DrawTopTen($a,$t,"Test");

function DrawTopTen($a, $t, $title)
{
	$graph = new Graph(768, 360);
	if(isset($_GET['d']) and $_GET['d'] === 'ming') {
		$graph->setDriver('ming');
	}

	$graph->setBackgroundColor(new Color(0xF4, 0xF4, 0xF4));
	$graph->shadow->setSize(3);

	$graph->title->set($title);
	$graph->title->setFont(new Tuffy(15));
	$graph->title->setColor(new Color(0x00, 0x00, 0x8B));


	$group = new PlotGroup;
	$group->setSize(0.82, 1);
	$group->setCenter(0.41, 0.5);
	$group->setPadding(35, 26, 40, 27);
	$group->setSpace(2, 2);

	$group->grid->setColor(new Color(0xC4, 0xC4, 0xC4));
	$group->grid->setType(Line::DASHED);
	$group->grid->hideVertical(TRUE);
	$group->grid->setBackgroundColor(new White);

	$group->axis->left->setColor(new DarkGreen);
	$group->axis->left->label->setFont(new Font2);

	$group->axis->right->setColor(new DarkBlue);
	$group->axis->right->label->setFont(new Font2);

	$group->axis->bottom->label->setFont(new Font2);

	$group->legend->setPosition(1.18);
	$group->legend->setTextFont(new Tuffy(8));
	$group->legend->setSpace(12);

	// Add a bar plot
	$x = array($a[0], 0, 0, 0, 0, 0, 0, 0, 0, 0 );

	$plot = new BarPlot($x, 2, 2);
	$plot->setBarColor(new VeryDarkRed); //MidYellow
	$plot->setBarPadding(0.15, 0.15);
	$plot->barShadow->setSize(3);
	$plot->barShadow->smooth(TRUE);
	$plot->barShadow->setColor(new Color(200, 200, 200, 10));

	$group->legend->add($plot, $t[0], Legend::BACKGROUND);
	$group->add($plot);

	// Add a bar plot
	$x = array(0, $a[1], 0, 0, 0, 0, 0, 0, 0, 0 );

	$plot = new BarPlot($x, 2, 2);
	$plot->setBarColor(new Color(120, 175, 80, 10));
	$plot->setBarPadding(0.15, 0.15);
	$plot->barShadow->setSize(3);
	$plot->barShadow->smooth(TRUE);
	$plot->barShadow->setColor(new Color(200, 200, 200, 10));

	$group->legend->add($plot, $t[1], Legend::BACKGROUND);
	$group->add($plot);

	// Add a second bar plot
	$x = array(0, 0, $a[2], 0, 0, 0, 0, 0, 0, 0 );

	$plot = new BarPlot($x, 2, 2);
	$plot->setBarColor(new Orange);
	$plot->setBarPadding(0.15, 0.15);
	$plot->barShadow->setSize(3);
	$plot->barShadow->smooth(TRUE);
	$plot->barShadow->setColor(new Color(200, 200, 200, 10));

	$group->legend->add($plot, $t[2], Legend::BACKGROUND);
	$group->add($plot);

	$x = array(0, 0, 0, $a[3], 0, 0, 0, 0, 0, 0 );

	$plot = new BarPlot($x, 2, 2);
	$plot->setBarColor(new DarkGray);
	$plot->setBarPadding(0.15, 0.15);
	$plot->barShadow->setSize(3);
	$plot->barShadow->smooth(TRUE);
	$plot->barShadow->setColor(new Color(200, 200, 200, 10));

	$group->legend->add($plot, $t[3], Legend::BACKGROUND);
	$group->add($plot);

	$x = array(0, 0, 0, 0, $a[4], 0, 0, 0, 0, 0 );

	$plot = new BarPlot($x, 2, 2);
	$plot->setBarColor(new MidYellow);
	$plot->setBarPadding(0.15, 0.15);
	$plot->barShadow->setSize(3);
	$plot->barShadow->smooth(TRUE);
	$plot->barShadow->setColor(new Color(200, 200, 200, 10));

	$group->legend->add($plot, $t[4], Legend::BACKGROUND);
	$group->add($plot);

	$x = array(0, 0, 0, 0, 0, $a[5], 0, 0, 0, 0 );

	$plot = new BarPlot($x, 2, 2);
	$plot->setBarColor(new Magenta);
	$plot->setBarPadding(0.15, 0.15);
	$plot->barShadow->setSize(3);
	$plot->barShadow->smooth(TRUE);
	$plot->barShadow->setColor(new Color(200, 200, 200, 10));

	$group->legend->add($plot, $t[5], Legend::BACKGROUND);
	$group->add($plot);

	$x = array(0, 0, 0, 0, 0, 0, $a[6], 0, 0, 0 );
	$plot = new BarPlot($x, 2, 2);
	$plot->setBarColor(new DarkCyan);
	$plot->setBarPadding(0.15, 0.15);
	$plot->barShadow->setSize(3);
	$plot->barShadow->smooth(TRUE);
	$plot->barShadow->setColor(new Color(200, 200, 200, 10));

	$group->legend->add($plot, $t[6], Legend::BACKGROUND);
	$group->add($plot);

	$x = array(0, 0, 0, 0, 0, 0, 0, $a[7], 0, 0 );
	$plot = new BarPlot($x, 2, 2);
	$plot->setBarColor(new LightBlue);
	$plot->setBarPadding(0.15, 0.15);
	$plot->barShadow->setSize(3);
	$plot->barShadow->smooth(TRUE);
	$plot->barShadow->setColor(new Color(200, 200, 200, 10));

	$group->legend->add($plot, $t[7], Legend::BACKGROUND);
	$group->add($plot);

	$x = array(0, 0, 0, 0, 0, 0, 0, 0, $a[8], 0 );
	$plot = new BarPlot($x, 2, 2);
	$plot->setBarColor(new Red);
	$plot->setBarPadding(0.15, 0.15);
	$plot->barShadow->setSize(3);
	$plot->barShadow->smooth(TRUE);
	$plot->barShadow->setColor(new Color(200, 200, 200, 10));

	$group->legend->add($plot, $t[8], Legend::BACKGROUND);
	$group->add($plot);

	$x = array(0, 0, 0, 0, 0, 0, 0, 0, 0, $a[9] );
	$plot = new BarPlot($x, 2, 2);
	$plot->setBarColor(new Blue);
	$plot->setBarPadding(0.15, 0.15);
	$plot->barShadow->setSize(3);
	$plot->barShadow->smooth(TRUE);
	$plot->barShadow->setColor(new Color(200, 200, 200, 10));

	$group->legend->add($plot, $t[9], Legend::BACKGROUND);
	$group->add($plot);

	$graph->add($group);
	$graph->draw();
}
?>
